import pymysql

class DB:
    def __init__(self):
        self.conn = pymysql.connect(host='127.0.0.1',port=3306,user='root',password='caobaofu5.9',db='p6_2',charset='utf8',cursorclass=pymysql.cursors.DictCursor)
        #获取游标
        self.cousor = self.conn.cursor()
#添加
    def insert(self,sql):
        self.cousor.execute(sql)
        self.conn.commit()
#查找所有
    def findall(self,sql):
        self.cousor.execute(sql)
        return self.cousor.fetchall()






db1 = DB()